<?php

/**
 * Dummy class
 * Used by singleton classes to help encourage programmers to use the &getInstace method to init the class, instead of directly creating the creator
 * This is achived by making the constructor require a parameter that must be a reference to this class!
 *
 * DO NOT call directly, must be extended
 * 
 * @author Ben Rowe
 */
class SingletonEnforcer
{
	/**
	 * Display an error warning that the object being created MUST be called via the getInstance method
	 *
	 */
	function _enforceSingletonWarning()
	{
		die('You must not call this class directly. Please call this class by calling the getInstance method statically!');
	}
	
	/**
	 * Verifies that this object is being generated via the getInstance method
	 * This must be called from the child constructor (first line)
	 *
	 * @access private
	 * @param SingletonEnforcer $object
	 * @return void
	 */
	function _verifySingleton($object)
	{
		if(!is_a($object, 'SingletonEnforcer')) {
			$this->_enforceSingletonWarning();
		}
	}
	
}

?>